package com.traffic.service.impl;

import java.util.List;

import cn.hutool.core.convert.Convert;
import com.ruoyi.common.core.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.traffic.mapper.CondolenceMoneyApplicationMapper;
import com.traffic.domain.CondolenceMoneyApplication;
import com.traffic.service.ICondolenceMoneyApplicationService;

/**
 * 慰问金申请Service业务层处理
 *
 * @author ywt
 * @date 2024-10-12
 */
@Service
public class CondolenceMoneyApplicationServiceImpl implements ICondolenceMoneyApplicationService {
    @Autowired
    private CondolenceMoneyApplicationMapper condolenceMoneyApplicationMapper;

    /**
     * 查询慰问金申请
     *
     * @param id 慰问金申请主键
     * @return 慰问金申请
     */
    @Override
    public CondolenceMoneyApplication selectCondolenceMoneyApplicationById(Long id) {
        return condolenceMoneyApplicationMapper.selectCondolenceMoneyApplicationById(id);
    }

    /**
     * 查询慰问金申请列表
     *
     * @param condolenceMoneyApplication 慰问金申请
     * @return 慰问金申请
     */
    @Override
    public List<CondolenceMoneyApplication> selectCondolenceMoneyApplicationList(CondolenceMoneyApplication condolenceMoneyApplication) {
        return condolenceMoneyApplicationMapper.selectCondolenceMoneyApplicationList(condolenceMoneyApplication);
    }

    /**
     * 新增慰问金申请
     *
     * @param condolenceMoneyApplication 慰问金申请
     * @return 结果
     */
    @Override
    public int insertCondolenceMoneyApplication(CondolenceMoneyApplication condolenceMoneyApplication) {
        condolenceMoneyApplication.setCreateTime(DateUtils.getNowDate());
        return condolenceMoneyApplicationMapper.insertCondolenceMoneyApplication(condolenceMoneyApplication);
    }

    /**
     * 修改慰问金申请
     *
     * @param condolenceMoneyApplication 慰问金申请
     * @return 结果
     */
    @Override
    public int updateCondolenceMoneyApplication(CondolenceMoneyApplication condolenceMoneyApplication) {
        String amountLower = condolenceMoneyApplication.getAmountLower();
        double v = Double.parseDouble(amountLower);
        String s = Convert.digitToChinese(v);
        condolenceMoneyApplication.setAmountUpper(s);
        return condolenceMoneyApplicationMapper.updateCondolenceMoneyApplication(condolenceMoneyApplication);
    }

    /**
     * 批量删除慰问金申请
     *
     * @param ids 需要删除的慰问金申请主键
     * @return 结果
     */
    @Override
    public int deleteCondolenceMoneyApplicationByIds(Long[] ids) {
        return condolenceMoneyApplicationMapper.deleteCondolenceMoneyApplicationByIds(ids);
    }

    /**
     * 删除慰问金申请信息
     *
     * @param id 慰问金申请主键
     * @return 结果
     */
    @Override
    public int deleteCondolenceMoneyApplicationById(Long id) {
        return condolenceMoneyApplicationMapper.deleteCondolenceMoneyApplicationById(id);
    }
}
